﻿//Write an expression that checks if given positive integer number n (n ≤ 100) is prime. E.g. 37 is prime

using System;

class IfIntegerIsPrime
{
    static void Main()
    {
        Console.Write("Enter positive number to check if it's prime: ");
        int number = int.Parse(Console.ReadLine());

        if (number > 0 && number <= 100)
        {
            if (isPrime(number))
                Console.WriteLine("The number {0} is prime.", number);
            else
                Console.WriteLine("The number {0} is NOT primer.", number);
        }
        else
            Console.WriteLine("Your number is out of range (Conditions: n > 0 and <=100).");
    }

    private static bool isPrime(int number)
    {
        if (number == 1)
            return false;
        for (int i = 2; i < Math.Sqrt(number); i++)
        {
            if (number % i == 0)
                return false;
        }
        return true;
    }
}